
import { isString } from "@/utils/is"
import { ref, watch } from "vue"

export const useTitle = (newTitle?: string) => {
  const title = ref(newTitle)
  watch(title, (n, o) => {
    if (isString(n) && n !== o && document) {
      document.title = (n as string)
    }
  }, { immediate: true })
  return title
}